<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="Start" href="index.html">
<link rel="previous" href="Printast.html">
<link rel="next" href="Printf.html">
<link rel="Up" href="index.html">
<link title="Index of types" rel=Appendix href="index_types.html">
<link title="Index of exceptions" rel=Appendix href="index_exceptions.html">
<link title="Index of values" rel=Appendix href="index_values.html">
<link title="Index of modules" rel=Appendix href="index_modules.html">
<link title="Index of module types" rel=Appendix href="index_module_types.html">
<link title="Arg" rel="Chapter" href="Arg.html">
<link title="Arg_helper" rel="Chapter" href="Arg_helper.html">
<link title="Array" rel="Chapter" href="Array.html">
<link title="ArrayLabels" rel="Chapter" href="ArrayLabels.html">
<link title="Ast_helper" rel="Chapter" href="Ast_helper.html">
<link title="Ast_invariants" rel="Chapter" href="Ast_invariants.html">
<link title="Ast_iterator" rel="Chapter" href="Ast_iterator.html">
<link title="Ast_mapper" rel="Chapter" href="Ast_mapper.html">
<link title="Asttypes" rel="Chapter" href="Asttypes.html">
<link title="Attr_helper" rel="Chapter" href="Attr_helper.html">
<link title="Bigarray" rel="Chapter" href="Bigarray.html">
<link title="Buffer" rel="Chapter" href="Buffer.html">
<link title="Builtin_attributes" rel="Chapter" href="Builtin_attributes.html">
<link title="Bytes" rel="Chapter" href="Bytes.html">
<link title="BytesLabels" rel="Chapter" href="BytesLabels.html">
<link title="Callback" rel="Chapter" href="Callback.html">
<link title="CamlinternalFormat" rel="Chapter" href="CamlinternalFormat.html">
<link title="CamlinternalFormatBasics" rel="Chapter" href="CamlinternalFormatBasics.html">
<link title="CamlinternalLazy" rel="Chapter" href="CamlinternalLazy.html">
<link title="CamlinternalMod" rel="Chapter" href="CamlinternalMod.html">
<link title="CamlinternalOO" rel="Chapter" href="CamlinternalOO.html">
<link title="Ccomp" rel="Chapter" href="Ccomp.html">
<link title="Char" rel="Chapter" href="Char.html">
<link title="Clflags" rel="Chapter" href="Clflags.html">
<link title="Complex" rel="Chapter" href="Complex.html">
<link title="Condition" rel="Chapter" href="Condition.html">
<link title="Config" rel="Chapter" href="Config.html">
<link title="Consistbl" rel="Chapter" href="Consistbl.html">
<link title="Depend" rel="Chapter" href="Depend.html">
<link title="Digest" rel="Chapter" href="Digest.html">
<link title="Docstrings" rel="Chapter" href="Docstrings.html">
<link title="Dynlink" rel="Chapter" href="Dynlink.html">
<link title="Ephemeron" rel="Chapter" href="Ephemeron.html">
<link title="Event" rel="Chapter" href="Event.html">
<link title="Filename" rel="Chapter" href="Filename.html">
<link title="Format" rel="Chapter" href="Format.html">
<link title="Gc" rel="Chapter" href="Gc.html">
<link title="Genlex" rel="Chapter" href="Genlex.html">
<link title="Graphics" rel="Chapter" href="Graphics.html">
<link title="GraphicsX11" rel="Chapter" href="GraphicsX11.html">
<link title="Hashtbl" rel="Chapter" href="Hashtbl.html">
<link title="Identifiable" rel="Chapter" href="Identifiable.html">
<link title="Int32" rel="Chapter" href="Int32.html">
<link title="Int64" rel="Chapter" href="Int64.html">
<link title="Lazy" rel="Chapter" href="Lazy.html">
<link title="Lexer" rel="Chapter" href="Lexer.html">
<link title="Lexing" rel="Chapter" href="Lexing.html">
<link title="List" rel="Chapter" href="List.html">
<link title="ListLabels" rel="Chapter" href="ListLabels.html">
<link title="Location" rel="Chapter" href="Location.html">
<link title="Longident" rel="Chapter" href="Longident.html">
<link title="Map" rel="Chapter" href="Map.html">
<link title="Marshal" rel="Chapter" href="Marshal.html">
<link title="Misc" rel="Chapter" href="Misc.html">
<link title="MoreLabels" rel="Chapter" href="MoreLabels.html">
<link title="Mutex" rel="Chapter" href="Mutex.html">
<link title="Nativeint" rel="Chapter" href="Nativeint.html">
<link title="Numbers" rel="Chapter" href="Numbers.html">
<link title="Obj" rel="Chapter" href="Obj.html">
<link title="Oo" rel="Chapter" href="Oo.html">
<link title="Parse" rel="Chapter" href="Parse.html">
<link title="Parser" rel="Chapter" href="Parser.html">
<link title="Parsetree" rel="Chapter" href="Parsetree.html">
<link title="Parsing" rel="Chapter" href="Parsing.html">
<link title="Pervasives" rel="Chapter" href="Pervasives.html">
<link title="Pparse" rel="Chapter" href="Pparse.html">
<link title="Pprintast" rel="Chapter" href="Pprintast.html">
<link title="Printast" rel="Chapter" href="Printast.html">
<link title="Printexc" rel="Chapter" href="Printexc.html">
<link title="Printf" rel="Chapter" href="Printf.html">
<link title="Profile" rel="Chapter" href="Profile.html">
<link title="Queue" rel="Chapter" href="Queue.html">
<link title="Random" rel="Chapter" href="Random.html">
<link title="Scanf" rel="Chapter" href="Scanf.html">
<link title="Set" rel="Chapter" href="Set.html">
<link title="Simplif" rel="Chapter" href="Simplif.html">
<link title="Sort" rel="Chapter" href="Sort.html">
<link title="Spacetime" rel="Chapter" href="Spacetime.html">
<link title="Stack" rel="Chapter" href="Stack.html">
<link title="StdLabels" rel="Chapter" href="StdLabels.html">
<link title="Str" rel="Chapter" href="Str.html">
<link title="Stream" rel="Chapter" href="Stream.html">
<link title="String" rel="Chapter" href="String.html">
<link title="StringLabels" rel="Chapter" href="StringLabels.html">
<link title="Strongly_connected_components" rel="Chapter" href="Strongly_connected_components.html">
<link title="Syntaxerr" rel="Chapter" href="Syntaxerr.html">
<link title="Sys" rel="Chapter" href="Sys.html">
<link title="Targetint" rel="Chapter" href="Targetint.html">
<link title="Tbl" rel="Chapter" href="Tbl.html">
<link title="Terminfo" rel="Chapter" href="Terminfo.html">
<link title="Thread" rel="Chapter" href="Thread.html">
<link title="ThreadUnix" rel="Chapter" href="ThreadUnix.html">
<link title="Typemod" rel="Chapter" href="Typemod.html">
<link title="Uchar" rel="Chapter" href="Uchar.html">
<link title="Unix" rel="Chapter" href="Unix.html">
<link title="UnixLabels" rel="Chapter" href="UnixLabels.html">
<link title="Warnings" rel="Chapter" href="Warnings.html">
<link title="Weak" rel="Chapter" href="Weak.html"><link title="Raw backtraces" rel="Section" href="#1_Rawbacktraces">
<link title="Current call stack" rel="Section" href="#1_Currentcallstack">
<link title="Uncaught exceptions" rel="Section" href="#1_Uncaughtexceptions">
<link title="Manipulation of backtrace information" rel="Section" href="#1_Manipulationofbacktraceinformation">
<link title="Raw backtrace slots" rel="Section" href="#1_Rawbacktraceslots">
<link title="Exception slots" rel="Section" href="#1_Exceptionslots">
<title>Printexc</title>
</head>
<body>
<div class="navbar"><a class="pre" href="Printast.html" title="Printast">Previous</a>
&nbsp;<a class="up" href="index.html" title="Index">Up</a>
&nbsp;<a class="post" href="Printf.html" title="Printf">Next</a>
</div>
<h1>Module <a href="type_Printexc.html">Printexc</a></h1>

<pre><span id="MODULEPrintexc"><span class="keyword">module</span> Printexc</span>: <code class="code"><span class="keyword">sig</span></code> <a href="Printexc.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info module top">
<div class="info-desc">
<p>Facilities for printing exceptions and inspecting current call stack.</p>
</div>
</div>
<hr width="100%">

<pre><span id="VALto_string"><span class="keyword">val</span> to_string</span> : <code class="type">exn -> string</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code"><span class="constructor">Printexc</span>.to_string&nbsp;e</code> returns a string representation of
   the exception <code class="code">e</code>.</p>
</div>
</div>

<pre><span id="VALprint"><span class="keyword">val</span> print</span> : <code class="type">('a -> 'b) -> 'a -> 'b</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code"><span class="constructor">Printexc</span>.print&nbsp;fn&nbsp;x</code> applies <code class="code">fn</code> to <code class="code">x</code> and returns the result.
   If the evaluation of <code class="code">fn&nbsp;x</code> raises any exception, the
   name of the exception is printed on standard error output,
   and the exception is raised again.
   The typical use is to catch and report exceptions that
   escape a function application.</p>
</div>
</div>

<pre><span id="VALcatch"><span class="keyword">val</span> catch</span> : <code class="type">('a -> 'b) -> 'a -> 'b</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code"><span class="constructor">Printexc</span>.catch&nbsp;fn&nbsp;x</code> is similar to <a href="Printexc.html#VALprint"><code class="code"><span class="constructor">Printexc</span>.print</code></a>, but
   aborts the program with exit code 2 after printing the
   uncaught exception.  This function is deprecated: the runtime
   system is now able to print uncaught exceptions as precisely
   as <code class="code"><span class="constructor">Printexc</span>.catch</code> does.  Moreover, calling <code class="code"><span class="constructor">Printexc</span>.catch</code>
   makes it harder to track the location of the exception
   using the debugger or the stack backtrace facility.
   So, do not use <code class="code"><span class="constructor">Printexc</span>.catch</code> in new code.</p>
</div>
</div>

<pre><span id="VALprint_backtrace"><span class="keyword">val</span> print_backtrace</span> : <code class="type"><a href="Pervasives.html#TYPEout_channel">out_channel</a> -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code"><span class="constructor">Printexc</span>.print_backtrace&nbsp;oc</code> prints an exception backtrace
    on the output channel <code class="code">oc</code>.  The backtrace lists the program
    locations where the most-recently raised exception was raised
    and where it was propagated through function calls.</p>

<p>If the call is not inside an exception handler, the returned
    backtrace is unspecified. If the call is after some
    exception-catching code (before in the handler, or in a when-guard
    during the matching of the exception handler), the backtrace may
    correspond to a later exception than the handled one.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 3.11.0</li>
</ul>
</div>

<pre><span id="VALget_backtrace"><span class="keyword">val</span> get_backtrace</span> : <code class="type">unit -> string</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code"><span class="constructor">Printexc</span>.get_backtrace&nbsp;()</code> returns a string containing the
    same exception backtrace that <code class="code"><span class="constructor">Printexc</span>.print_backtrace</code> would
    print. Same restriction usage than <a href="Printexc.html#VALprint_backtrace"><code class="code"><span class="constructor">Printexc</span>.print_backtrace</code></a>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 3.11.0</li>
</ul>
</div>

<pre><span id="VALrecord_backtrace"><span class="keyword">val</span> record_backtrace</span> : <code class="type">bool -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code"><span class="constructor">Printexc</span>.record_backtrace&nbsp;b</code> turns recording of exception backtraces
    on (if <code class="code">b&nbsp;=&nbsp;<span class="keyword">true</span></code>) or off (if <code class="code">b&nbsp;=&nbsp;<span class="keyword">false</span></code>).  Initially, backtraces
    are not recorded, unless the <code class="code">b</code> flag is given to the program
    through the <code class="code"><span class="constructor">OCAMLRUNPARAM</span></code> variable.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 3.11.0</li>
</ul>
</div>

<pre><span id="VALbacktrace_status"><span class="keyword">val</span> backtrace_status</span> : <code class="type">unit -> bool</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code"><span class="constructor">Printexc</span>.backtrace_status()</code> returns <code class="code"><span class="keyword">true</span></code> if exception
    backtraces are currently recorded, <code class="code"><span class="keyword">false</span></code> if not.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 3.11.0</li>
</ul>
</div>

<pre><span id="VALregister_printer"><span class="keyword">val</span> register_printer</span> : <code class="type">(exn -> string option) -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code"><span class="constructor">Printexc</span>.register_printer&nbsp;fn</code> registers <code class="code">fn</code> as an exception
    printer.  The printer should return <code class="code"><span class="constructor">None</span></code> or raise an exception
    if it does not know how to convert the passed exception, and <code class="code"><span class="constructor">Some</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;s</code> with <code class="code">s</code> the resulting string if it can convert the passed
    exception. Exceptions raised by the printer are ignored.</p>

<p>When converting an exception into a string, the printers will be invoked
    in the reverse order of their registrations, until a printer returns
    a <code class="code"><span class="constructor">Some</span>&nbsp;s</code> value (if no such printer exists, the runtime will use a
    generic printer).</p>

<p>When using this mechanism, one should be aware that an exception backtrace
    is attached to the thread that saw it raised, rather than to the exception
    itself. Practically, it means that the code related to <code class="code">fn</code> should not use
    the backtrace if it has itself raised an exception before.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 3.11.2</li>
</ul>
</div>
<h2 id="1_Rawbacktraces">Raw backtraces</h2>
<pre><span id="TYPEraw_backtrace"><span class="keyword">type</span> <code class="type"></code>raw_backtrace</span> </pre>
<div class="info ">
<div class="info-desc">
<p>The abstract type <code class="code">raw_backtrace</code> stores a backtrace in
    a low-level format, instead of directly exposing them as string as
    the <code class="code">get_backtrace()</code> function does.</p>

<p>This allows delaying the formatting of backtraces to when they are
    actually printed, which may be useful if you record more
    backtraces than you print.</p>

<p>Raw backtraces cannot be marshalled. If you need marshalling, you
    should use the array returned by the <code class="code">backtrace_slots</code> function of
    the next section.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.01.0</li>
</ul>
</div>


<pre><span id="VALget_raw_backtrace"><span class="keyword">val</span> get_raw_backtrace</span> : <code class="type">unit -> <a href="Printexc.html#TYPEraw_backtrace">raw_backtrace</a></code></pre><div class="info ">
<div class="info-desc">
<p><code class="code"><span class="constructor">Printexc</span>.get_raw_backtrace&nbsp;()</code> returns the same exception
    backtrace that <code class="code"><span class="constructor">Printexc</span>.print_backtrace</code> would print, but in
    a raw format. Same restriction usage than <a href="Printexc.html#VALprint_backtrace"><code class="code"><span class="constructor">Printexc</span>.print_backtrace</code></a>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.01.0</li>
</ul>
</div>

<pre><span id="VALprint_raw_backtrace"><span class="keyword">val</span> print_raw_backtrace</span> : <code class="type"><a href="Pervasives.html#TYPEout_channel">out_channel</a> -> <a href="Printexc.html#TYPEraw_backtrace">raw_backtrace</a> -> unit</code></pre><div class="info ">
<div class="info-desc">
<p>Print a raw backtrace in the same format
    <code class="code"><span class="constructor">Printexc</span>.print_backtrace</code> uses.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.01.0</li>
</ul>
</div>

<pre><span id="VALraw_backtrace_to_string"><span class="keyword">val</span> raw_backtrace_to_string</span> : <code class="type"><a href="Printexc.html#TYPEraw_backtrace">raw_backtrace</a> -> string</code></pre><div class="info ">
<div class="info-desc">
<p>Return a string from a raw backtrace, in the same format
    <code class="code"><span class="constructor">Printexc</span>.get_backtrace</code> uses.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.01.0</li>
</ul>
</div>

<pre><span id="VALraise_with_backtrace"><span class="keyword">val</span> raise_with_backtrace</span> : <code class="type">exn -> <a href="Printexc.html#TYPEraw_backtrace">raw_backtrace</a> -> 'a</code></pre><div class="info ">
<div class="info-desc">
<p>Reraise the exception using the given raw_backtrace for the
    origin of the exception</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.05.0</li>
</ul>
</div>
<h2 id="1_Currentcallstack">Current call stack</h2>
<pre><span id="VALget_callstack"><span class="keyword">val</span> get_callstack</span> : <code class="type">int -> <a href="Printexc.html#TYPEraw_backtrace">raw_backtrace</a></code></pre><div class="info ">
<div class="info-desc">
<p><code class="code"><span class="constructor">Printexc</span>.get_callstack&nbsp;n</code> returns a description of the top of the
    call stack on the current program point (for the current thread),
    with at most <code class="code">n</code> entries.  (Note: this function is not related to
    exceptions at all, despite being part of the <code class="code"><span class="constructor">Printexc</span></code> module.)</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.01.0</li>
</ul>
</div>
<h2 id="1_Uncaughtexceptions">Uncaught exceptions</h2>
<pre><span id="VALset_uncaught_exception_handler"><span class="keyword">val</span> set_uncaught_exception_handler</span> : <code class="type">(exn -> <a href="Printexc.html#TYPEraw_backtrace">raw_backtrace</a> -> unit) -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code"><span class="constructor">Printexc</span>.set_uncaught_exception_handler&nbsp;fn</code> registers <code class="code">fn</code> as the handler
    for uncaught exceptions. The default handler prints the exception and
    backtrace on standard error output.</p>

<p>Note that when <code class="code">fn</code> is called all the functions registered with
    <a href="Pervasives.html#VALat_exit"><code class="code">at_exit</code></a> have already been called. Because of this you must
    make sure any output channel <code class="code">fn</code> writes on is flushed.</p>

<p>Also note that exceptions raised by user code in the interactive toplevel
    are not passed to this function as they are caught by the toplevel itself.</p>

<p>If <code class="code">fn</code> raises an exception, both the exceptions passed to <code class="code">fn</code> and raised
    by <code class="code">fn</code> will be printed with their respective backtrace.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.02.0</li>
</ul>
</div>
<h2 id="1_Manipulationofbacktraceinformation">Manipulation of backtrace information</h2>
<p>These functions are used to traverse the slots of a raw backtrace
    and extract information from them in a programmer-friendly format.</p>

<pre><span id="TYPEbacktrace_slot"><span class="keyword">type</span> <code class="type"></code>backtrace_slot</span> </pre>
<div class="info ">
<div class="info-desc">
<p>The abstract type <code class="code">backtrace_slot</code> represents a single slot of
    a backtrace.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.02</li>
</ul>
</div>


<pre><span id="VALbacktrace_slots"><span class="keyword">val</span> backtrace_slots</span> : <code class="type"><a href="Printexc.html#TYPEraw_backtrace">raw_backtrace</a> -> <a href="Printexc.html#TYPEbacktrace_slot">backtrace_slot</a> array option</code></pre><div class="info ">
<div class="info-desc">
<p>Returns the slots of a raw backtrace, or <code class="code"><span class="constructor">None</span></code> if none of them
    contain useful information.</p>

<p>In the return array, the slot at index <code class="code">0</code> corresponds to the most
    recent function call, raise, or primitive <code class="code">get_backtrace</code> call in
    the trace.</p>

<p>Some possible reasons for returning <code class="code"><span class="constructor">None</span></code> are as follow:</p>
<ul>
<li>none of the slots in the trace come from modules compiled with
    debug information (<code class="code">-g</code>)</li>
<li>the program is a bytecode program that has not been linked with
    debug information enabled (<code class="code">ocamlc&nbsp;-g</code>)</li>
</ul>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.02.0</li>
</ul>
</div>

<pre><code><span id="TYPElocation"><span class="keyword">type</span> <code class="type"></code>location</span> = {</code></pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTlocation.filename">filename</span>&nbsp;: <code class="type">string</code>;</code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTlocation.line_number">line_number</span>&nbsp;: <code class="type">int</code>;</code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTlocation.start_char">start_char</span>&nbsp;: <code class="type">int</code>;</code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTlocation.end_char">end_char</span>&nbsp;: <code class="type">int</code>;</code></td>

</tr></table>
}

<div class="info ">
<div class="info-desc">
<p>The type of location information found in backtraces. <code class="code">start_char</code>
    and <code class="code">end_char</code> are positions relative to the beginning of the
    line.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.02</li>
</ul>
</div>


<pre><span id="MODULESlot"><span class="keyword">module</span> <a href="Printexc.Slot.html">Slot</a></span>: <code class="code"><span class="keyword">sig</span></code> <a href="Printexc.Slot.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info">
</div>
<h2 id="1_Rawbacktraceslots">Raw backtrace slots</h2>
<pre><span id="TYPEraw_backtrace_slot"><span class="keyword">type</span> <code class="type"></code>raw_backtrace_slot</span> </pre>
<div class="info ">
<div class="info-desc">
<p>This type allows direct access to raw backtrace slots, without any
    conversion in an OCaml-usable data-structure. Being
    process-specific, they must absolutely not be marshalled, and are
    unsafe to use for this reason (marshalling them may not fail, but
    un-marshalling and using the result will result in
    undefined behavior).</p>

<p>Elements of this type can still be compared and hashed: when two
    elements are equal, then they represent the same source location
    (the converse is not necessarily true in presence of inlining,
    for example).</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.02.0</li>
</ul>
</div>


<pre><span id="VALraw_backtrace_length"><span class="keyword">val</span> raw_backtrace_length</span> : <code class="type"><a href="Printexc.html#TYPEraw_backtrace">raw_backtrace</a> -> int</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">raw_backtrace_length&nbsp;bckt</code> returns the number of slots in the
    backtrace <code class="code">bckt</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.02</li>
</ul>
</div>

<pre><span id="VALget_raw_backtrace_slot"><span class="keyword">val</span> get_raw_backtrace_slot</span> : <code class="type"><a href="Printexc.html#TYPEraw_backtrace">raw_backtrace</a> -> int -> <a href="Printexc.html#TYPEraw_backtrace_slot">raw_backtrace_slot</a></code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">get_raw_backtrace_slot&nbsp;bckt&nbsp;pos</code> returns the slot in position <code class="code">pos</code> in the
    backtrace <code class="code">bckt</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.02</li>
</ul>
</div>

<pre><span id="VALconvert_raw_backtrace_slot"><span class="keyword">val</span> convert_raw_backtrace_slot</span> : <code class="type"><a href="Printexc.html#TYPEraw_backtrace_slot">raw_backtrace_slot</a> -> <a href="Printexc.html#TYPEbacktrace_slot">backtrace_slot</a></code></pre><div class="info ">
<div class="info-desc">
<p>Extracts the user-friendly <code class="code">backtrace_slot</code> from a low-level
    <code class="code">raw_backtrace_slot</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.02</li>
</ul>
</div>

<pre><span id="VALget_raw_backtrace_next_slot"><span class="keyword">val</span> get_raw_backtrace_next_slot</span> : <code class="type"><a href="Printexc.html#TYPEraw_backtrace_slot">raw_backtrace_slot</a> -> <a href="Printexc.html#TYPEraw_backtrace_slot">raw_backtrace_slot</a> option</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">get_raw_backtrace_next_slot&nbsp;slot</code> returns the next slot inlined, if any.</p>

<p>Sample code to iterate over all frames (inlined and non-inlined):</p>
<pre class="codepre"><code class="code">      <span class="comment">(* Iterate over inlined frames *)</span>
      <span class="keyword">let</span> <span class="keyword">rec</span> iter_raw_backtrace_slot f slot =
        f slot;
        <span class="keyword">match</span> get_raw_backtrace_next_slot slot <span class="keyword">with</span>
        <span class="keywordsign">|</span> <span class="constructor">None</span> <span class="keywordsign">-&gt;</span> ()
        <span class="keywordsign">|</span> <span class="constructor">Some</span> slot' <span class="keywordsign">-&gt;</span> iter_raw_backtrace_slot f slot'

      <span class="comment">(* Iterate over stack frames *)</span>
      <span class="keyword">let</span> iter_raw_backtrace f bt =
        <span class="keyword">for</span> i = 0 <span class="keyword">to</span> raw_backtrace_length bt - 1 <span class="keyword">do</span>
          iter_raw_backtrace_slot f (get_raw_backtrace_slot bt i)
        <span class="keyword">done</span>
    </code></pre></div>
<ul class="info-attributes">
<li><b>Since</b> 4.04.0</li>
</ul>
</div>
<h2 id="1_Exceptionslots">Exception slots</h2>
<pre><span id="VALexn_slot_id"><span class="keyword">val</span> exn_slot_id</span> : <code class="type">exn -> int</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code"><span class="constructor">Printexc</span>.exn_slot_id</code> returns an integer which uniquely identifies
    the constructor used to create the exception value <code class="code">exn</code>
    (in the current runtime).</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.02.0</li>
</ul>
</div>

<pre><span id="VALexn_slot_name"><span class="keyword">val</span> exn_slot_name</span> : <code class="type">exn -> string</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code"><span class="constructor">Printexc</span>.exn_slot_name&nbsp;exn</code> returns the internal name of the constructor
    used to create the exception value <code class="code">exn</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.02.0</li>
</ul>
</div>
</body></html>